function init() {
	tinyMCEPopup.resizeToInnerSize();

	var inst = tinyMCE.selectedInstance;
}

//Sends the selected page to the editor as a link
function updateAction() {
	var formObj = document.forms[0];
	var page = getCheckedValue(formObj.elements['page']);
	if(page != ""){
		var href = pages[page][0];
		var title = pages[page][1];
		
		myValue = "<a href='"+href+"' title='"+title+"'>"+title+"</a> ";
		
		
		tinyMCEPopup.restoreSelection();
		
		tinyMCE.execCommand("mceInsertContent",true,myValue);
		tinyMCEPopup.close();
	}else{
		alert("Please select a page.");
	}
}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}